﻿using Dovey.Framework;
using GenericAndReflection.DAL;
using GenericAndReflection.IDAL;
using GenericAndReflection.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenericAndReflection
{
    class Program
    {
        static void Main(string[] args)
        {

            //从数据库中获取数据
            try
            {
                IBaseDAL helper = new BaseDAL();
                #region 获取某个实体

                //var user = helper.FindOne<User>(1);
                ////Console.WriteLine($"USER:{JsonConvert.SerializeObject(user)}");
                //user.Show();

                //var company = helper.FindOne<Company>(1);
                ////Console.WriteLine($"Company:{JsonConvert.SerializeObject(company)}");
                //company.Show();
                #endregion

                #region 获取全部记录
                //var userList =  helper.FindAll<User>();
                ////Console.WriteLine($"User List:{JsonConvert.SerializeObject(userList)}");
                //userList.ShowList();

                //var companyList = helper.FindAll<Company>();
                ////Console.WriteLine($"Company List:{JsonConvert.SerializeObject(companyList)}");
                //companyList.ShowList();
                #endregion

                {
                    User dovey = new User()
                    {
                        Account="Dovey",
                        CompanyId  = 1,
                        CompanyName = "Study",
                        CreateTime = DateTime.Now,
                        //CreatorId = 1,
                        Email = "17@qq.com",
                        LastLoginTime = DateTime.Now,
                        
                    };
                    helper.Add(dovey);
                }

                Console.ReadKey();
            }
            catch (Exception ex)
            {

                throw;
            }
            
           
        }
    }
}
